package com.soxing.webrain.brush.dao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.soxing.webrain.brush.dao.entity.Testee;
import com.soxing.webrain.brush.dao.mapper.TesteeMapper;
import com.soxing.webrain.brush.dao.service.ITesteeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.soxing.webrain.brush.common.util.PageUtils;
import com.soxing.webrain.brush.common.util.Query;

import java.util.Map;

@Service
public class TesteeServiceImpl extends ServiceImpl<TesteeMapper, Testee> implements ITesteeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<Testee> page;
        if(params.get("sort").equals("0")){
            page = this.page(
                    new Query<Testee>().getPage(params),
                    new QueryWrapper<Testee>().orderByDesc("id")
            );
        } else {
            page = this.page(
                    new Query<Testee>().getPage(params),
                    new QueryWrapper<Testee>()
            );
        }
        return new PageUtils(page);
    }
}
